package com.monitor.service.impl;

import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.monitor.dao.ErpRefuelingMapper;
import com.monitor.entity.ErpRefueling;
import com.monitor.service.ErpRefuelingService;
import com.monitor.util.Result;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 加油记录表 服务实现类
 * </p>
 *
 * @author LX
 * @since 2018-09-13
 */
@Service
@Transactional
public class ErpRefuelingServiceImpl extends ServiceImpl<ErpRefuelingMapper, ErpRefueling> implements ErpRefuelingService {
	@Resource
	private ErpRefuelingMapper erpRefuelingMapper;
	@Override
	public Result<List<ErpRefueling>> getrefuelingId(String startTime, String endTime, Integer custId) {
		// TODO Auto-generated method stub
		StringBuffer sb=new StringBuffer("");
		if(startTime!=null&&!startTime.equals("")) {
			sb.append(" and r.ref_dt >= '"+startTime+"'");
		}
		if(startTime!=null&&!startTime.equals("")) {
			sb.append(" and r.ref_dt <= '"+endTime+"'");
		}
		List<ErpRefueling> list=erpRefuelingMapper.selectByCustId1(custId, sb.toString());
		return new Result<List<ErpRefueling>>(list, list.size());
	}

	@Override
	public Double getRefuleMoneySum(Integer customerId) {
		return   erpRefuelingMapper.getRefuleMoneySum(customerId);
	}

}
